package com.example.blueconn.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

import com.example.blueconn.App;
import com.example.blueconn.R;
import com.example.blueconn.fragment.HomeFragment;
import com.example.blueconn.fragment.ReportFragment;
import com.example.blueconn.fragment.ShowDetailFragment;
import com.example.blueconn.fragment.listener.CallListener;

import java.util.ArrayList;
import java.util.List;

public class DataGenerator {
    public static final int[] tabRes = new int[]{R.drawable.tab_home_icon_selector, R.drawable.tab_home_chart_selector, R.drawable.tab_configure_icon_selector};
    public static final String[] titles = new String[]{App.getContext().getString(R.string.app_home),
            App.getContext().getString(R.string.app_chart),
            App.getContext().getString(R.string.app_configure)};

    public static List<Fragment> getFragments(CallListener listener) {
        List<Fragment> fragments = new ArrayList<>();
        ReportFragment reportFragment = ReportFragment.newInstance();
        fragments.add(reportFragment);
        Bundle bundle = new Bundle();
        fragments.add(ShowDetailFragment.newInstance(bundle));
        HomeFragment homeFragment = HomeFragment.newInstance();
        homeFragment.setCallListener(listener);
        fragments.add(homeFragment);
        return fragments;
    }

    public static View getTabView(Context context, int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.tab_content, null);
        ImageView icon = view.findViewById(R.id.icon);
        TextView title = view.findViewById(R.id.text);
        icon.setImageResource(tabRes[position]);
        title.setText(titles[position]);
        return view;
    }
}
